﻿@model NUS.ISS.SRKBS.UI.Models.Regulatory
@{
    ViewBag.Title = "Index";
}

<h1>Regulatory System</h1>            


@using (Ajax.BeginForm("RegulatoryRuleTrigger", "Regulatory", new AjaxOptions
{
    UpdateTargetId = "divRegulatoryRule",
    InsertionMode = InsertionMode.Replace,
    HttpMethod = "POST"
}))
{
    
    <fieldset>
        <h1>General Details</h1>
        <table>
            <tr>
                <td>@Html.LabelFor(m => m.ProjectName)</td>
                <td>
                    @Html.TextBoxFor(m => m.ProjectName)
                    @Html.ValidationMessageFor(m => m.ProjectName)
                </td>
            </tr>
            <tr>
                <td>@Html.Label("Generate")</td>
                <td>
                    @Html.CheckBoxFor(m => m.ReportCertificationPlan)
                    @Html.LabelFor(m => m.ReportCertificationPlan, new { @class = "checkbox" })
                    @Html.CheckBoxFor(m => m.ReportMarkingMatrix)
                    @Html.LabelFor(m => m.ReportMarkingMatrix, new { @class = "checkbox" })
                </td>
            </tr>
            <tr>
                <td>@Html.LabelFor(m => m.ProductId)</td>
                <td>
                    @Html.RadioButtonFor(m => m.ProductId, "H", new { id = "Product_Headphone" }) @Html.Label("Headphone", new { @class = "radio" })
                    @Html.RadioButtonFor(m => m.ProductId, "O", new { id = "Product_Others" }) @Html.Label("Others", new { @class = "radio" })
                </td>
            </tr>
        </table>        
    </fieldset>
           
}

<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $("#Product_Headphone").change(function () {
            var selected_product = $(this).val();
            var url = '@Url.Action("RegulatoryRuleTrigger", "Regulatory")';
            $.post(url, { ProductId: selected_product },
            function (data) {
                $('#divRequlatoryRule').empty().html(data);             
            });
            
        });

        $("#Product_Others").change(function () {
            var selected_product = $(this).val();
            var url = '@Url.Action("RegulatoryRuleTrigger", "Regulatory")';            
            $.post(url, { ProductId: selected_product },
                function (data) {
                    $('#divRequlatoryRule').empty().html(data); 
                });
        });
    });

   
</script>

<div id="divRequlatoryRule">
    @{Html.RenderPartial("_RegulatoryRulePartial", Model);}       
</div>